<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue中的样式绑定</title>
    <script src="./vue.js"></script>
</head>
<body>

<!--<div id="app">-->
<!--<div :style="[styleObj, {fontSize: '20px'}]" @click="handleDivClick">-->
<!--Hello world-->
<!--</div>-->
<!--</div>-->

<div id="app">
    <div :style="[styleObj,{fontSize:'40px'}]" @click="btn">okok</div>
</div>

<script>
    var vm = new Vue({
        el: "#app",
        data: {
            styleObj: {
                color: "black"
            }
        },
        methods: {
            btn: function () {
                this.styleObj.color = this.styleObj.color === "black" ? "red" : "black";
            }
        }
    })
</script>
</body>
</html>